import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.AirlineReservationServiceProxy;
import bean.Employee;
import bean.Traveler;
import constants.AirlineReservationServiceConstants;
 

public class ListCustomersServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		
		AirlineReservationServiceProxy proxy = new AirlineReservationServiceProxy(
				AirlineReservationServiceConstants.SERVICE_URL);
		Traveler[] travelers = proxy.listCustomers();
		List<Traveler> lstTravelers = new ArrayList<Traveler>();
		
		
		if(travelers!= null)
			lstTravelers = Arrays.asList(travelers);
			
		req.setAttribute("lstCustomers", lstTravelers);
		req.setAttribute("from", req.getParameter("from"));
		req.getRequestDispatcher("listCustomer.jsp").forward(req, resp);
			
			
			
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}
}
